package client;

import static debug.Debug.DBUG;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class Player extends Unit implements KeyListener {
	
	private static final int STEP_SIZE = 2;
	private ServerConnection conn;
	
	public Player(ServerConnection conn, int x, int y) {
		super(x, y);
		this.conn = conn;
	}

	
	@Override
	public void keyPressed(KeyEvent e) {
		int dx=0,dy=0;
		switch (e.getKeyCode()) {
		case KeyEvent.VK_LEFT:
			dx=-2;
			break;
		case KeyEvent.VK_RIGHT:
			dx=2;
			break;
		case KeyEvent.VK_UP:
			dy=-2;
			break;
		case KeyEvent.VK_DOWN:
			dy=2;
		}
		conn.sendMove(x+dx, y+dy);
	}
	
	public void keyReleased(KeyEvent arg0) { }
	public void keyTyped(KeyEvent arg0) {}
}
